﻿using XFControls.XFPanels;
using XFControls.XFPanels.XFPanelItems;
using XFSenseUI.XFItems;
using System.Drawing;
using System.Reflection;

namespace XFSenseUI
{
    public partial class SenseListPanel : XFPanelList
    {
        public SenseListPanel()
        {
            var bc = Color.FromArgb(239, 235, 239);
            if (Parent != null)
                Parent.BackColor = bc;
            BackColor = bc;
            InitializeComponent();
        }

        public SenseListPanel(SenseListPanel panel)
        {
            ClearItems();
            lock (_items)
                foreach (var itm in panel._items)
                    Add(itm);
        }

        public void AddSenseItem(SenseItemBase item)
        {
            item.State = XFItemState.Normal;

            int height = 0;

            if (item.Parent == null)
                item.Parent = this;
            item.OnAdd();

            lock (_items)
            {
                _items.Add(item);
                foreach (var itm in _items)
                {
                    height += itm.GetHeight();
                }
            }
            setHeight(height);
        }

        protected override void Dispose()
        {
            base.Dispose();
        }
    }
}
